//-----------------------------------------------------------------------
// <copyright file="FriendServiceBase.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using Pyco;
using Pyco.Diagnostics;
using Pyco.Data;
using BirthdayReminder.Entities;
using BirthdayReminder.Data;
    
namespace BirthdayReminder.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class FriendServiceBase
    {
        #region FriendServiceBase

        public static void CreateFriend(Friend friend)
        {            
            try
            {
                FriendDAO friendDAO = new FriendDAO();
                friendDAO.CreateFriend(friend);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessCreateFriendException, ex);
            }
        }

        public static void UpdateFriend(Friend friend)
        {            
            try
            {
                FriendDAO friendDAO = new FriendDAO();
                friendDAO.UpdateFriend(friend);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessUpdateFriendException, ex);
            }
        }        

        public static void DeleteFriend(int userId, int friendId)
        {            
            try
            {
                FriendDAO friendDAO = new FriendDAO();
                friendDAO.DeleteFriend(userId, friendId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessDeleteFriendException, ex);
            }
        }
		
        public static Friend GetFriend(int userId, int friendId)
        {            
            try
            {
                FriendDAO friendDAO = new FriendDAO();
                return friendDAO.GetFriend(userId, friendId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetFriendException, ex);
            }
        }                
		
        public static FriendCollection GetFriendList(FriendColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                FriendDAO friendDAO = new FriendDAO();
                return friendDAO.GetFriendList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetFriendListException, ex);
            }
        }        

        public static FriendCollection GetFriendList(FriendColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                FriendDAO friendDAO = new FriendDAO();
                return friendDAO.GetFriendList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetFriendListException, ex);
            }
        }        
		
		
        #endregion
    }
}